﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using System;

[TestClass()]
public class BullsAndCowsTest
{
    [TestMethod]
    public void GenerateSecretLenghtTest()
    {
        string result = BullsAndCows_Accessor.GenerateSecret(5);
        Assert.AreEqual(result.Length, 5);
    }

    [TestMethod]
    public void GenerateSecretDifferentCharsTest()
    {
        string result = BullsAndCows_Accessor.GenerateSecret(5);
        HashSet<char> container = new HashSet<char>(result);
        Assert.AreEqual(5, container.Count);
    }

    
    [TestMethod]
    [ExpectedException(typeof(ArgumentException))]
    public void MoreThan10WordTest()
    {
        string result = BullsAndCows_Accessor.GenerateSecret(11);
        Assert.AreEqual(10, result.Length);
    }

    [TestMethod]
    public void GetBullsAllCorrectTest()
    {
        BullsAndCows_Accessor.secret = "1234";
        int result = BullsAndCows_Accessor.GetBulls("1234");
        int expected = 4;
        Assert.AreEqual(result, expected);
    }

    [TestMethod]
    public void GetBullsFullCowsTest()
    {
        BullsAndCows_Accessor.secret = "4321";
        int result = BullsAndCows_Accessor.GetBulls("1234");
        int expected = 0;
        Assert.AreEqual(result, expected);
    }

    [TestMethod]
    public void GetCowsFullCowsTest()
    {
        BullsAndCows_Accessor.secret = "4321";
        int result = BullsAndCows_Accessor.GetCows("1234");
        int expected = 4;
        Assert.AreEqual(result, expected);
    }

    [TestMethod]
    public void GetCowsFullBullsTest()
    {
        BullsAndCows_Accessor.secret = "4321";
        int result = BullsAndCows_Accessor.GetCows("1234");
        int expected = 4;
        Assert.AreEqual(result, expected);
    }

    [TestMethod]
    public void GetCowsHalfBullsHalfCowsTest()
    {
        BullsAndCows_Accessor.secret = "2345";
        int result = BullsAndCows_Accessor.GetCows("2354");
        int expected = 4;
        Assert.AreEqual(result, expected);
    }

    [TestMethod]
    public void RespondTest()
    {
        BullsAndCows_Accessor.secret = "1234";
        bool allCorrect = false;
        BullsAndCows_Accessor.Respond("1234",ref allCorrect);        
        Assert.IsTrue(allCorrect); 
    }

    [TestMethod]
    public void ReadNumberTest()
    {
        BullsAndCows_Accessor.secret = "1234";
        bool allCorrect = false;
        BullsAndCows_Accessor.ReadNumber("1234", ref allCorrect);
        Assert.IsTrue(allCorrect);
    }
}